import { Context, Next } from 'koa';

import { Controller, Get } from '../core/decorators/controller';

/**
 * 注意controllers目录下最好不要存放非控制器代码
 */

@Controller('/example')
export class ExampleController {
  @Get('/:id')
  async getOne(ctx: Context, next: Next) {
    const { id } = ctx.params as { id: string };
    ctx.status = 200;
    ctx.type = 'json';
    ctx.body = {
      code: 200,
      success: true,
      message: 'success',
      result: {
        name: 'example',
        id,
      },
    };
    await next();
  }
}
